import java.util.Arrays;

public class SolutionInterview1_8 {
    public void setZeroes(int[][] matrix) {
        for (int i=0;i<matrix.length;i++){
            for (int j=0;j<matrix[0].length;j++){
                if (matrix[i][j]==0){
                    for (int k=0;k<matrix[0].length;k++){
                        if (matrix[i][k]!=0){
                            matrix[i][k]=Integer.MAX_VALUE/3;
                        }
                    }
                    for (int k=0;k<matrix.length;k++){
                        if (matrix[k][j]!=0){
                            matrix[k][j]=Integer.MAX_VALUE/3;
                        }
                    }
                }
            }
        }
        for (int i=0;i<matrix.length;i++){
            for (int j=0;j<matrix[0].length;j++){
                if (matrix[i][j]==Integer.MAX_VALUE/3){
                    matrix[i][j]=0;
                }
            }
        }
    }

    public static void main(String[] args) {
        int[][] f=new int[][]{{1,1,1},{1,0,1},{1,1,1}};
        new SolutionInterview1_8().setZeroes(f);
        System.out.println(Arrays.deepToString(f));
    }
}
